package xyz.xtt.exchange.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.exchange.service.ICarouseImageService;
import xyz.xtt.exchange.service.IIndexService;
import xyz.xtt.exchange.vo.BannerVo;

/**
 * 首页
 * 
 * @author huqibo
 * @date 2025/03/24
 */
@Slf4j
@RequestMapping("/api/exchange")
@RestController
public class IndexController {
	@Autowired
	private ICarouseImageService carouseImageService;
	@Autowired
	private IIndexService iIndexService;

	// 查询 banner
	@GetMapping("/banner")
	public ApiResult<List<BannerVo>> banner() {
		return ApiResult.ok(carouseImageService.getBanner());
	}

//	@GetMapping("/index/list")
//	public ApiResult<List<NftListVo>> list(@RequestHeader("uid") Long uid, @RequestParam(value = "type", defaultValue = "1") Integer type, // 1 热卖榜， 2 平台自营， 3
//			@RequestParam(value = "currPage", defaultValue = "1") Integer currPage, @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
//			@RequestParam(value = "sortType", defaultValue = "") String sortType, @RequestParam(value = "sortOrder", defaultValue = "desc") String sortOrder) {
//		return ApiResult.ok(tblAssetService.getIndexList(uid, currPage, pageSize, SortType.fromValue(sortType), SortOrder.fromValue(sortOrder)));
//	}
	@GetMapping("/index/list")
	public ApiResult<List<NftListVo>> list(@RequestHeader("uid") Long uid, @RequestParam(value = "type", defaultValue = "1") Integer type, // 1 热卖榜， 2 平台自营， 3
			@RequestParam(value = "currPage", defaultValue = "1") Integer currPage, @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
			@RequestParam(value = "sortType", defaultValue = "") String sortType, @RequestParam(value = "sortOrder", defaultValue = "desc") String sortOrder) {
		List<NftListVo> index = iIndexService.index(uid, type, currPage, pageSize, sortType, sortOrder);
		return ApiResult.ok(index);
	}

}
